package com.google.code.sprite;

import com.google.code.sprite.generate.ListPageGenerate;
import com.google.code.sprite.generate.BasicGenerate;
import java.util.List;


import com.google.code.sprite.conf.SpriteConfig;
import com.google.code.sprite.conf.TableConfig;
import com.google.code.sprite.generate.ActionGenerate;
import com.google.code.sprite.generate.ConfigGenerate;
import com.google.code.sprite.generate.DaoGenerate;
import com.google.code.sprite.generate.DaoImplGenerate;
import com.google.code.sprite.generate.EditPageGenerate;
import com.google.code.sprite.generate.EntityGenerate;
import com.google.code.sprite.generate.ServiceGenerate;
import com.google.code.sprite.generate.ServiceImplGenerate;
import com.google.code.sprite.generate.TableMetaData;

public class CodeSprite {

    public static void main(String[] args) {
        SpriteConfig spriteConfig = SpriteConfig.getInstance();

        List<TableConfig> tableConfigs = spriteConfig.getTableConfigs();
        BasicGenerate[] generators = new BasicGenerate[] {
            new EntityGenerate(), 
            new DaoGenerate(),
            new DaoImplGenerate(),
            new ActionGenerate(),
            new ServiceImplGenerate(),
            new ServiceGenerate(),
            new EditPageGenerate(),
            new ListPageGenerate(),
            new ConfigGenerate() } ;


        for (TableConfig tableConfig : tableConfigs) {
            TableMetaData tableMetaData = new TableMetaData(tableConfig.getDbName());

            for (BasicGenerate generator : generators ) {
                generator.writeToFile(tableConfig, tableMetaData);
            }
        }
    }

}



